package com.example.springboot26.controller;

import com.example.springboot26.expection.UserNotExistException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Map;

/**
 * 项目名称：springboot26
 * 类 名 称：HelloController
 * 类 描 述：TODO
 * 创建时间：2020/2/2 2:43 下午
 */
@Controller
public class HelloController {

    @ResponseBody
    @RequestMapping("/hello")
    public String hello(@RequestParam("user") String user) {
        if (user.equals("aaa")) {
            throw new UserNotExistException();
        }
        return "hello";
    }

    // 查出一些数据在页面展示
    @RequestMapping("/success")
    public String success(Map<String, Object> map) {
        map.put("hello", "<h1>武汉加油</h1>");
        map.put("users", Arrays.asList("Ann", "Bob", "Cook"));
        return "success";
    }

//    @RequestMapping({"/", "/index.html"})
//    public String index() {
//        return "index";
//    }
}
